﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using Microsoft.VisualStudio.TestTools.UnitTesting;

using Otonomos.World;

namespace Test.Otonomos.World
{
    [TestClass]
    public class TestPoint2D
    {
        [TestMethod]
        public void CreatePoint()
        {
            var point = new Point2D();
            Assert.AreEqual(point.X, 0.0);
            Assert.AreEqual(point.Y, 0.0);

            var otherPoint = new Point2D(2.0, 3.0);
            Assert.AreEqual(otherPoint.X, 2.0);
            Assert.AreEqual(otherPoint.Y, 3.0);
        }

        [TestMethod]
        public void ComparePoints()
        {
            var point = new Point2D();
            Assert.AreEqual(point, Point2D.Origin);
            Assert.AreEqual(point, Point2D.Origin);

            var otherPoint = new Point2D(3.0, 5.0);
            Assert.AreNotEqual(otherPoint, point);
            Assert.IsFalse(otherPoint == point);
            Assert.IsFalse(otherPoint.Equals(Point2D.Origin));

            var thirdPoint = new Point2D(3.0, 5.0);
            Assert.AreEqual(otherPoint, thirdPoint);
            Assert.IsTrue(otherPoint == thirdPoint);
            Assert.IsTrue(thirdPoint.Equals(otherPoint));
        }

        [TestMethod]
        public void CheckDistance()
        {
            var point = new Point2D(1.0, 2.0);
            var otherPoint = new Point2D(5.0, 5.0);
            Assert.AreEqual(point.Distance(otherPoint), 5.0);
        }
    }
}
